<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>${filename}</title>
		<%@include file="/context/mytags.jsp"%>
		<t:base type="jquery"></t:base>
		<script type="text/javascript" src="video/ckplayer_6/ckplayer/ckplayer.js" charset="utf-8"></script>
		<script type="text/javascript">
		
			var ptime = 0;
			<c:if test="${lcw!=null&&courseware.duration>lcw.sc}">
				ptime = ${lcw.sc};
			</c:if>
			var watchTime = ptime;
			<c:if test="${lcw!=null}">
				watchTime = ${lcw.sc};		//如果超过视频长度的
			</c:if>
			//定时器
			function uploadLearnTime(){
				var kcid = "${kcid}";
				var xsid = "${xsid}";
				var kjid = "${courseware.id}";
				if(!xsid || xsid == ""){
					return;
				}else{	//计算时间
					$.ajax( {    
					    url:'coursewareController.do?uploadLearnTime&kcid='+kcid+"&kjid="+kjid+"&xsid="+xsid+"&sc="+watchTime,// 跳转到 action   
					    type:'post',    
					    cache:false,    
					    dataType:'json',    
					    success:function(data){    
					    	
					    },    
					    error : function(){    
					    	
					    }    
					}); 
				}
			}
			
			window.setInterval(uploadLearnTime,10000); 
	
		 	function loadedHandler() {
	            if (CKobject.getObjectById('ckplayer_a1').getType()) {
	                addPlayListener();
	                CKobject.getObjectById('ckplayer_a1').addListener('paused','pausedHandler');
	            }
	            else {
	                addPlayListener();
	                CKobject.getObjectById('ckplayer_a1').addListener('paused','pausedHandler');
	            }
	        }
		 	var setT=null;
		 	function pausedHandler(b){
		 	    if(setT){
		 	      	window.clearInterval(setT);
		 	 	}
		 	    if(!b){
		 	      	setT=window.setInterval(setFunction,1000);
		 	    }
		 	}
		 	function setFunction(){
		 	    watchTime+=1;
		 	}
		 	
	        function addPlayListener() {//增加播放监听
	            if (CKobject.getObjectById('ckplayer_a1').getType()) {//说明使用html5播放器
	                CKobject.getObjectById('ckplayer_a1').addListener('play', playHandler);
	            }
	            else {
	                CKobject.getObjectById('ckplayer_a1').addListener('play', 'playHandler');
	            }
	        }
	        function playHandler() {
	            //alert('因为注册了监听播放，所以弹出此内容，删除监听将不再弹出');
	            removePlayListener();
	            CKobject.getObjectById('ckplayer_a1').videoSeek(ptime);
	        }
	        function removePlayListener() {//删除播放监听事件
	            if (CKobject.getObjectById('ckplayer_a1').getType()) {//说明使用html5播放器
	                CKobject.getObjectById('ckplayer_a1').removeListener('play', playHandler);
	            }
	            else {
	                CKobject.getObjectById('ckplayer_a1').removeListener('play', 'playHandler');
	            }
	        }
		</script>
	</head>
	<body>
		<div style="color: red;font-size: 14px;">
			请在阅读完成课件之后，点击关闭按钮。如果非法关闭浏览器会导致学习时间无效。
		</div>	
		<div id="video"
			style="position: relative; z-index: 100; width: 700px; height: 500px;left: 5px; top: 25px;">
			<div id="a1"></div>
		</div>
		<script>
		var flashvars = {
		    f: '${path}',
		    c: 0,
		    p: 2,
		    b: 0,
		    i: '/static/images/letitgo.jpg',
		    loaded: 'loadedHandler',
		    my_url: encodeURIComponent(window.location.href)
		  };
     	var params={bgcolor:'#FFF',allowFullScreen:true,allowScriptAccess:'always',wmode:'transparent'};
     	CKobject.embedSWF('video/ckplayer_6/ckplayer/ckplayer.swf','a1','ckplayer_a1','700','500',flashvars,params);
	</script>
	
	</body>
</html>